package com.datastructures2.字符串;

/**
 * @author MaoLin Wang
 * @date 2020/10/4 10:37 下午
 */
public class replaceSpace {

    public static String replace(String str){

        StringBuilder sb=new StringBuilder();
        for (char c : str.toCharArray()) {
            if (String.valueOf(c).equals(" ")){
                sb.append("%20");
            }else {
                sb.append(c);
            }
        }
        return sb.toString() ;
    }

    public static void main(String[] args) {
        System.out.println(replace("aa bb cc  ss"));
    }
}
